mystr = 'hello world and itcast and itheima and Python ands'
print(mystr.rfind('and'))
print(mystr[35])
print(mystr.find('ands',15,30))
print(mystr.index('ands'))
print(mystr.count('and',0,20))
print(mystr.rsplit(' '))
print(mystr.replace('and','he'))
print(mystr.rsplit(' ',2))
str="Hello, Python! I love Python programming."
index = str.find('Python')
print(str.find('Python'))
if str.find('Python')>0:
    print(str.replace('Python','Java'))
mystr =" hello world and itcast and itheima and Python  "
print(mystr.upper())
print(mystr.lower())
print((mystr.rstrip()).capitalize())
print(mystr.capitalize())
print(mystr.center(100,"."))
mystr = 'hello'
print(mystr.center(10,'#'))
name= '****'
list = [[1,2,3],[4,5,6],[7,8,9,10]]
print(name.endswith('Tom',0,3))
list_new = [a[i ]for a in list for i in range(len(a))]
print(list_new)
mystr = 'fall!lafjsdl!lafjdl!lfadjl!'
print(mystr.index('!'))
print(mystr.find('!',mystr.index('!')+1))
def find(a):
    mystr1 = 'hello'
    mystr2 = ('hello12345')
    print(mystr1.isalpha())
    print(mystr2.isalpha())
    print(mystr1.isdigit())
    print(mystr2.isdigit())
    print(mystr1.isalnum())
    print(mystr1.isspace())


def findstr(list,str,num):
    index_temp=0
    index_now = 0
    for i in range(num):
        index_temp=index_now
        index_now= list.find(str,index_temp+1)
    return index_now

name_list =['111','222','333']

name = (input('请输入您要搜索的名字：'))

if name in name_list:
    print(f'您输入的名字是{name}，名字已存在')
else:
    name_list.extend(name)
    print(f'您输入的名字是{name}，名字不存在，已添加')

print(name_list)
name_list.insert(1,'333')
print(name_list)
del name_list[1]
name_list.pop()
name_list.remove('111')
name_list[0]='aaa'
print (name_list)

num_list = [2,4,6,8,1,3,564,14,3678,465,4,63,32,2]
num_list.sort()
num_list.sort()
num_list.reverse()
print(num_list)

i = 0
while i<len(num_list):

    print(num_list[i])
    i = i + 1
for i in num_list:
    print(i)

dict = {'name':'Tom','age':20,'gender':'男'}
print(dict['name'])
print(dict.get('nam',123))
for key in dict.keys():
    print(key)
print(dict.items())
for value in dict.values():
    print(value)
for key,value in dict.items():
    print(f'{key} = {value}')
set = {i for i in range(10) if i%2==0}
print(set)
list = [1,2,3,4,5,3]
dict = {n:n**2 for n in range(10)}
print(dict)

age = int(input('请输入你的年龄：'))

if age>18:
    print('，和格牛马已成年，可以上网。')
elif age == 18:
    age = 18
    print('刚满18岁耶~，可以上网。')
else :
    print('未成年，不可以上网。')
print('系统关闭。')

age = int (input('请输入您的年龄：'))
if age<18:
    print(f'您的年龄是{age}，童工一枚')
elif age>=18 and age<=60:
    print(f'您的年龄是{age},合法工龄')
elif age>60:
    print(f'您的年龄是{age}，老邓可以退休')

money = 1
seat = 1
if money ==1:
    if seat==1:
        print('可以上车')
    else:
        print('不可以上车')

elif money !=1:
    print('穹币')